@ECHO OFF

IF %1 == "" GOTO :NoTarget

IF NOT EXIST ".\Releases" MD Releases

IF EXIST ".\Releases\"%1 GOTO :ReleaseExists 

PUSHD Releases
IF ERRORLEVEL 1 GOTO :BadFolder

MD %1
IF ERRORLEVEL 1 GOTO :BadFolder

PUSHD %1
IF ERRORLEVEL 1 GOTO :BadFolder

XCOPY ..\..\OR.Lazarus.Presentation\bin\release\*.dll . /i
XCOPY ..\..\OR.Lazarus.Presentation\bin\release\*.exe .
XCOPY ..\..\OR.Lazarus.Presentation\Source\*.* .\Source /i /s
XCOPY ..\..\OR.Lazarus.Presentation\Config\*.* .\Config /i /s
XCOPY ..\..\Transforms\*.* .\Transforms /i /s

REN OR.Lazarus.Presentation.exe Lazarus.exe

POPD
POPD

@ECHO Release %1 Created

:End
EXIT /b

:ReleaseExists
@ECHO The Release %1 already exists.
EXIT /b 1

:NoTarget
@ECHO Please specify a target release folder.
@ECHO   ex: CreateRelease 04.00
EXIT /b 1

:BadFolder
@ECHO There was an error creating the folder.
EXIT /b 1
